<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏商家合作平台</title>
    <script src="__JS__/jquery.js"></script>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script src="__STATIC__/boot/js/dropdown.js"></script>
</head>
<body>
{include file="base/header" /}

<table class="layui-table" style="text-align: center">
    <thead>
    <tr>
        <td>商品名称</td>
        <td>单价(元)</td>
        <td>购买个数(个)</td>
        <td>总价(元)</td>
        <td>描述</td>
        <td>快递公司</td>
        <td>运单号</td>
        <td>状态</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    {foreach $result as $val}
    <tr>
        <td>{$val.pname}</td>
        <td>{$val.purchaseprice}</td>
        <td>{$val.number}</td>
        <td>{$val.total}</td>
        <td onclick="describe({$val.id})">{$val.describe|substr=###,0,9}..详情</td>
        <td>{$val.express}</td>
        <td>{$val.oddnumber}</td>
        <td style="color: red">{if $val.status == 2 } 待处理 {elseif $val.status == 3/} 邮寄中 {elseif $val.status == 4/}货已到{elseif $val.status == 5 /}已完成 {/if}</td>
        <td>
            <button type="button" onclick="orderdetail({$val.id})" class="btn btn-info btn-xs">详情</button>
            {if $val.status == 2}
                <button type="button" onclick="delivergoods({$val.id})" class="btn btn-warning btn-xs">发货</button>
            {else/}
                <button type="button" disabled class="btn btn-warning btn-xs">发货</button>
            {/if}
            <!--<button type="button" onclick="number({$val.id})" class="btn btn-primary btn-xs">添加单号</button>-->
        </td>
    </tr>
    {/foreach}
    </tbody>
</table>
{$result->render()}
</body>
<script>
    //描述
    function describe(id) {
        layer.open({
            type:2,
            title:"描述",
            anim:2,
            area: ['500px', '400px'],
            content:"{:url('business/postpayment/describe')}?id="+id
        });
    }
    //发货
    function delivergoods(id) {
        layer.open({
            type:2,
            title:"添加物流信息",
            anim:2,
            area: ['500px', '450px'],
            content:"{:url('business/postpayment/express')}?id="+id
        });
    }
    //订单详情
    function orderdetail(id) {
        layer.open({
            type:2,
            title:"描述",
            anim:2,
            area: ['700px', '600px'],
            content:"{:url('business/postpayment/orderdetail')}?id="+id
        });
    }
    //添加单号
    function number(id) {
        layer.prompt({title: '请填写运单号', formType: 2},
            function (number) {
                if(!number){
                    layer.alert('请填写运单号');
                    return;
                }
                $.ajax({
                    url:"{:url('business/postpayment/number')}",
                    data:"id="+id+"&number="+number,
                    type:"post",
                    dataType:"json",
                    success:function (res) {
                        if(res.success){
                            layer.alert(res.success,{bnt:['确定']},function () {
                                location.reload();
                            });
                        }
                        if(res.error){
                            layer.alert(res.error);
                        }
                    }
                });
            }
        );
    }
</script>
</html>